﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_PzRuleSet_ErrorEntry.aspx.vb" Inherits="PubProject.Cwjk_PzRuleSet_ErrorEntry" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head runat="server">
    <title>异常凭证预警</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
	<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
	<meta content="JavaScript" name="vs_defaultClientScript">
	<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
	<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
	<script language="javascript" src="/_common/scripts/global.js"></script>
	<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
	<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
	<script language="javascript" src="/_controls/settings.aspx"></script>
	<script language="javascript" src="/_controls/util/util.js"></script>
	<style type="text/css">
	   .tdClass{ BORDER-left:#7B9EBD 1px solid;BORDER-top:#7B9EBD 1px solid;}
	</style>	
	<script language="javascript" src="/PubProject/Cwjk/Cwjk_Public.js"></script>
	<script language="javascript">
	    var _MyHelpfile = "/Cbgl/HELP/topics/财务人员/设置财务接口/设置凭证规则.html";
	    function document.onkeydown()
        {
            try
            {
                if (event.keyCode == 8)
                {
                    var s = event.srcElement.tagName;
                    if (s && s != "INPUT" && s != "TEXTAREA") 
                    {
                        event.returnValue = false;
                    }
                    else if (event.srcElement.type != "text")
                    {
                        event.returnValue = false;
                    }
                    else if (event.srcElement.readOnly)
                    {
                        event.returnValue = false;
                    }
                }
            }
            catch(e){}
        }
        function window.onload()
        {
            if (document.all["__Application"] && document.all["__Application"].value == "0101")
	        {
	            _MyHelpfile = "/Slxt/Help/topics/财务管理/财务接口设置/设置凭证规则.html";
	        }
        }
	    //选择会计科目
	    function SelectKjkm(obj)
	    {
            var oTr;
            oTr = obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
            var sKjkmGUID = oTr.KjkmGUID;
            var sCwztGUID = document.all["txtCwztGUID"].value;
            var sPath = "/PubProject/Cwjk/Cwjk_PzRuleSet_SelectKjkm.aspx";
            var sParam = "CwztGUID=" + sCwztGUID + "&KjkmGUID=" + sKjkmGUID ;
            
            var arrRtn = openMyDlg("选择会计科目", sPath, sParam, "",430,600);
            if (arrRtn)
            {
                oTr.JyKjkmGUID =arrRtn.KjkmGUID;
                obj.parentElement.previousSibling.firstChild.value = arrRtn.KjkmFullName;
            }
	    }
	    function SaveErrorEntry()
	    {
	        var arrCheckBox = document.getElementsByName("chkGroupName");
	        var bCheckPz = false;
	        for(var i=0 ; i <= arrCheckBox.length-1; i++)
	        {
	            if (arrCheckBox[i].checked)
	            {
	                bCheckPz = true;
	                break;
	            }
	        }
	        if(!bCheckPz)
	        {
	            alert("请选择凭证规则！");
	            return ;
	        }
	        //校验及收集凭证分录数据
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.loadXML('<PzEntryRules></PzEntryRules>');
	        for(var i=0 ; i <= arrCheckBox.length-1; i++)
	        {
	            if (arrCheckBox[i].checked)
	            {
	                var sFullGroupName = arrCheckBox[i].FullGroupName;
	                var sOperTypeGUID = arrCheckBox[i].OperTypeGUID;
	                var sPzOrderCode = arrCheckBox[i].PzOrderCode;
	                var oTable = document.all["PzTable"+sOperTypeGUID+sPzOrderCode];
	                
	                for (var j=1;j<= oTable.rows.length-1; j++)
	                {
	                    if(oTable.rows[j].IsYC == "1" )  
	                    {
	                       if(oTable.rows[j].JyKjkmGUID == "")
	                       {
    	                        alert("请选择“"+ sFullGroupName +"”的建议调整会计科目！");
	                            return;
	                       }
	                       var pzEntryEl = xmlDoc.createElement("PZ");
	                       pzEntryEl.setAttribute("PzEntryRuleGUID",oTable.rows[j].PzEntryRuleGUID);
	                       pzEntryEl.setAttribute("JyKjkmGUID",oTable.rows[j].JyKjkmGUID);
	                       xmlDoc.documentElement.appendChild(pzEntryEl);
	                    }
	                }
	            }
	        }
	        if(xmlDoc.documentElement.childNodes.length > 0)
	        {
	            //保存凭证分录规则
	            var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx?CwztGUID=" + document.all["txtCwztGUID"].value;
                var sReturns = openCwjkXmlHTTP(sFile,"SaveErrorEntry",xmlDoc.xml);
                if (sReturns != undefined)
                {
                    var arrRtn = sReturns.split("|")
                    if(arrRtn.length == 2)
                    {
                        if(arrRtn[0] == "YES")
                        {
                            //更新异常凭证数据
                            window.parent.document.all["lbl_ErrorPzNum"].innerText = arrRtn[1];
                            window.parent.showErrorEntry();
                        }
                        else
                        {
                            alert("保存异常凭证规则时出错，请联系管理员！");
                            return ;
                        }
                    }
                    else
                    {
                        alert("保存异常凭证规则时出错，请联系管理员！");
                        return ;
                    }
                }
	        }
	    }
	    function chgAll()
	    {
	        var arrCheckBox = document.getElementsByName("chkGroupName");
	        for(var i=0 ; i <= arrCheckBox.length-1; i++)
	        {
	            arrCheckBox[i].checked = document.all["chkAll"].checked;
	        }
	    }
	    
	</script>
</head>
<body style="BORDER:#7B9EBD 1px solid;MARGIN: 5px;background-color:#FFFBFF">
    <form id="form1" runat="server">
    <asp:textbox id="txtCwztGUID" runat="server" style="display:none"></asp:textbox>
    <asp:linkbutton id="lnkTmp" style="DISPLAY: none" Runat="server"></asp:linkbutton>
        <table style="TABLE-LAYOUT: fixed;FONT-SIZE:9pt; WIDTH: 100%; HEIGHT: 100%" cellSpacing="0" cellPadding="0">            
		    <tr>
			    <td valign="top">
				    <div id="div_ErrorEntry" style="height:expression((document.body.clientHeight-110)+'px');width:100%;overflow:auto;" runat="server" enableviewstate="False">
				    </div>
			    </td>
		    </tr>
		    <TR height="10"><TD></td></TR>
		    <TR height="50" id="tr_ErrorTip" style="display:none" runat="server">
		        <td>
		            <table>
		                <tr><TD ><INPUT TYPE="checkbox" id="chkAll" onclick="chgAll()"><label for="chkAll">全选/取消全选</label></INPUT></td></tr>
		                <tr><TD style="font-size:12;color='#FF0000';">&nbsp;黄色背景表示：原会计科目设置不正确！</td></tr>
		            </table></td>
    		    
		        </TR>
            <TR height="40" id="tr_SaveError" style="display:none" runat="server">
			    <TD class="buttons">
				    <TABLE style="WIDTH: 100%; HEIGHT: 100% " cellSpacing="0" cellPadding="0">
					    <TR>
						    <TD align="right">
							    <BUTTON style="WIDTH: 70px" onclick="SaveErrorEntry()" id="btnSave" type="button">执行调整</BUTTON>&nbsp;&nbsp;
							    <BUTTON style="WIDTH: 70px" onclick="parent.window.close();" id="btnClose" type="button">关 闭</BUTTON>
						    </TD>
					    </TR>
				    </TABLE>
			    </TD>
		    </TR>
        </table>
    </form>
</body>
</html>
